clear;
close all;
clc;

%============Change the following parameters
Sub_Pro = 2; % 3.2
% Sub_Pro = 3; % 3.3
for I_trial = 1:10 % change I_trial from 1 to 10, which will correspond to the values below.
    I_trial
    %============Do not change the following parameters
    Proto_Num = 3;
    % fs = 41000;
    fs = 44100;
    sides = {'Left'}; % fake for Protocol = 3


    eval(['load All_sound_recordings\Phonemes\Phoneme_' num2str(Proto_Num) '.' num2str(Sub_Pro) '\Phoneme_' num2str(Proto_Num) '.' num2str(Sub_Pro) '_' sides{1} '_'   num2str((I_trial)) 'degree.mat']);
    speech = recorded_sound; 
    load Protocol_0_0degree
    noise = recorded_sound(1:round(fs*10),:);
    load 'C:\Users\gaiy\OneDrive - Saint Louis University\speech_experiments\ori';
    recorded_sound=[noise
        speech
        ];% only need 10 s noise
    Filename= ['cut_Ps_noiseAudacity\Phoneme_' num2str(Proto_Num) '.' num2str(Sub_Pro) '\Phoneme_' num2str(Proto_Num) '.' num2str(Sub_Pro) '_' sides{1} '_'   num2str((I_trial)) 'degree.wav' ];

audiowrite(Filename,recorded_sound,fs);
pause(0.2)
end